import {request} from "@yaf/request";
import {toApi} from "@/service/proxyApi";
import {RequestDataType, RespDataType} from "./apiType";

export * from "./apiType";

const { get, postJSON, del, put } = request;

/**
 * 获取代理商分页列表
 */
export const getAgentPageList = (params: { page: number, pageSize: number, name?: string }) => {
    return get<RespDataType.AgentPageList>(toApi("api/v1/system/agent/pageList"), params);
}

/**
 * 创建代理商
 */
export const createAgent = (params: RequestDataType.CreateAgentItem) => {
    return postJSON(toApi("api/v1/system/agent/create"), params);
}

/**
 * 获取代理商信息
 */
export const getAgentInfo = (id: number) => {
    return get<RespDataType.AgentItem>(toApi("api/v1/system/agent/get"), {id});
}

/**
 * 更新代理商信息
 */
export const updateAgent = (id: number, params: Partial<RequestDataType.UpdateAgentItem>) => {
    return put(toApi(`api/v1/system/agent/update?id=${id}`), params);
}

/**
 * 删除代理商信息
 */
export const deleteAgent = (Ids: number[]) => {
    return del(toApi(`api/v1/system/agent/delete`), {Ids});
}

